<template>
<!-- 左边菜单 -->
  <el-menu default-active="2" :collapse="collapsed" collapse-transition router :default-active="$route.path" unique-opened class="el-menu-vertical-demo" background-color="#334157" text-color="#fff" active-text-color="#ffd04b">
    <div class="logobox">
      <img class="logoimg" src="../assets/logo_left.png" alt="">
    </div>
    <el-submenu v-for="menu in allmenu" :key="menu.menuid" :index="menu.menuname">
      <template slot="title">
        <i class="iconfont" :class="menu.icon"></i>
        <span>{{menu.menuname}}</span>
      </template>
      <el-menu-item-group>
        <el-menu-item v-for="chmenu in menu.menus" :index="'/'+chmenu.url" :key="chmenu.menuid">
          <i class="iconfont" :class="chmenu.icon"></i>
          <span>{{chmenu.menuname}}</span>
        </el-menu-item>
      </el-menu-item-group>
    </el-submenu>
  </el-menu>
</template>
<script>
// import { menu } from '../api/userMG'
export default {
  name: 'leftnav',
  data() {
    return {
      collapsed: false,
      allmenu: []
    }
  },
  // 创建完毕状态(里面是操作)
  created() {
    // 获取图形验证码
    let res = {
      success: true,
      data: [
        {
          menuid: 1,
          icon: 'el-icon-postcard',
          menuname: '驾照题库',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 2,
              icon: 'icon-cat-skuQuery',
              menuname: '科目一',
              hasThird: 'N',
              url: 'JK/jkOne',
              menus: null
            },
            {
              menuid: 3,
              icon: 'icon-cat-skuQuery',
              menuname: '科目四',
              hasThird: 'N',
              url: 'JK/jkFour',
              menus: null
            }
          ]
        },
        {
          menuid: 33,
          icon: 'el-icon-notebook-1',
          menuname: '图书电商数据',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 34,
              icon: 'icon-order-manage',
              menuname: '图书信息',
              hasThird: 'N',
              url: 'TUSHU/index',
              menus: null
            }
          ]
        },
        {
          menuid: 71,
          icon: 'el-icon-document-copy',
          menuname: '新闻头条',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 72,
              icon: 'icon-cus-manage',
              menuname: '头条新闻',
              hasThird: 'N',
              url: 'XW/toutiao',
              menus: null
            },
            {
              menuid: 73,
              icon: 'icon-news-manage',
              menuname: '社会新闻',
              hasThird: 'N',
              url: 'XW/shehui',
              menus: null
            },
            {
              menuid: 74,
              icon: 'icon-cs-manage',
              menuname: '国内新闻',
              hasThird: 'N',
              url: 'XW/guonei',
              menus: null
            },
            {
              menuid: 75,
              icon: 'icon-promotion-manage',
              menuname: '娱乐新闻',
              hasThird: 'N',
              url: 'XW/yule',
              menus: null
            },
            {
              menuid: 76,
              icon: 'icon-cms-manage',
              menuname: '体育新闻',
              hasThird: 'N',
              url: 'XW/tiyu',
              menus: null
            },
            {
              menuid: 77,
              icon: 'icon-cms-manage',
              menuname: '军事新闻',
              hasThird: 'N',
              url: 'XW/junshi',
              menus: null
            },
            {
              menuid: 78,
              icon: 'icon-cms-manage',
              menuname: '科技新闻',
              hasThird: 'N',
              url: 'XW/keji',
              menus: null
            },
            {
              menuid: 79,
              icon: 'icon-cms-manage',
              menuname: '财经新闻',
              hasThird: 'N',
              url: 'XW/caijing',
              menus: null
            },
            {
              menuid: 80,
              icon: 'icon-cms-manage',
              menuname: '时尚新闻',
              hasThird: 'N',
              url: 'XW/shishang',
              menus: null
            }
          ]
        },
        {
          menuid: 128,
          icon: 'el-icon-headset',
          menuname: '网易云音乐数据',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 175,
              icon: 'icon-provider-manage',
              menuname: '支付配置',
              hasThird: 'N',
              url: 'pay/Config',
              menus: null
            }
          ]
        },
        {
          menuid: 150,
          icon: 'el-icon-data-line',
          menuname: '暂停基金数据',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 159,
              icon: 'icon-provider-manage',
              menuname: '基金数据可视化',
              hasThird: 'N',
              url: 'ZTJJDATA/index',
              menus: null
            },
            {
              menuid: 160,
              icon: 'icon-provider-manage',
              menuname: '黄金数据',
              hasThird: 'N',
              url: 'ZTJJDATA/huangjinSJ',
              menus: null
            }
          ]
        }
      ],
      msg: 'success'
    }
          this.allmenu = res.data
    
    // this.$root.Bus.$on('toggle', value => {
    //   this.collapsed = !value
    // })
  }
}
</script>
<style>
.el-menu-vertical-demo:not(.el-menu--collapse) {
  width: 240px;
  min-height: 400px;
}
.el-menu-vertical-demo:not(.el-menu--collapse) {
  border: none;
  text-align: left;
}
.el-menu-item-group__title {
  padding: 0px;
}
.el-menu-bg {
  background-color: #1f2d3d !important;
}
.el-menu {
  border: none;
}
.logobox {
  height: 40px;
  line-height: 40px;
  color: #9d9d9d;
  font-size: 20px;
  text-align: center;
  padding: 10px 0px;
}
.logoimg {
  height: 40px;
}
</style>